
import sevenBin from '7zip-bin'
import Seven from 'node-7z' // 注意，这里要全部导入不能解构，否则可能还没加载完，直接使用会包裹
const pathTo7zip = sevenBin.path7za

export function un7z(filePath, targetPath) {
    return new Promise((resolve, reject) => {
        Seven.extractFull(filePath, targetPath, { $bin: pathTo7zip }, (err, stdout, stderr, cmd) => {
            if (err) {
                reject(err)
            } else {
                resolve(stdout)
            }
        }).on('end', () => {
            resolve('end')
        }).on('error', (err) => {
            reject(err)
        })
    })
}
